package com.darsystems.foghourz.server;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.users.User;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class FBServerInfoRecord {
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key id;

    @Persistent
    private String fbUserEmail;

    @Persistent
    private String fbUrl;
    
//    @Persistent
//    private String fbToken;

    public FBServerInfoRecord(User fbUser, String fbUrl) {
        this.id = createKey(fbUser);
    	this.fbUserEmail = fbUser.getEmail();
        this.fbUrl = fbUrl;
    }

    public Key getKey() {
        return id;
    }

    public void setKey(Key key) {
        this.id = key;
    }
    
    public String getFbUserEmail() {
        return fbUserEmail;
    }

    public String getFbUrl() {
        return fbUrl;
    }

    public void setFbUserEmail(User fbUser) {
        this.fbUserEmail = fbUser.getEmail();
    }

    public void setFbUrl(String fbUrl) {
        this.fbUrl = fbUrl;
    }
    
    public static Key createKey(User user){
    	return KeyFactory.createKey(FBServerInfoRecord.class.getSimpleName(), user.getEmail());
    }

//	public void setFbToken(String fbToken) {
//		this.fbToken = fbToken;
//	}
//
//	public String getFbToken() {
//		return fbToken;
//	}
}
